package com.carcenter.sms.listener;

import cn.hutool.core.util.RandomUtil;
import com.carcenter.common.dto.SmsDto;
import com.carcenter.common.result.Result;
import com.carcenter.sms.config.SmsTemplate;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;

import java.time.Duration;
import java.util.Map;

@Component
@Slf4j
public class telListener {
    @Autowired
    private SmsTemplate smsTemplate;

    /**
     * 监听邮件队列，发送邮件
     * 对指定的队列进行监听，并且将数据注入给方法的形参
     */
    @RabbitListener(queues = "tel.queue")
    public void listener(SmsDto smsDto) {
        log.info("\"监听到队列，开始发送短信\"");
        smsTemplate.sendSms(smsDto.getMobile(), smsDto.getCode());
        log.info("\"发送短信成功\"");

    }

}
